<?php
/**
 * @version $Id: pm_debit.php 16 2010-05-13 19:24:10Z vladzimirs@gmail.com $
 * @package UnoCart
 * @copyright Авторские права (C) 2009-2010 UnoCart team & (C) 2007-2010 Joostina team &. Все права защищены.
 * @license Лицензия http://www.gnu.org/licenses/gpl-2.0.htm GNU/GPL, или help/license.php
 * UnoCart! - свободное программное обеспечение распространяемое по условиям лицензии GNU/GPL
 * Для получения информации о используемых расширениях и замечаний об авторском праве, смотрите файл help/copyright.php.
 */
defined('_VALID_MOS') or die('Restricted access');
class pm_debit
{
    function showPaymentForm()
    {
        global $pm_debit;
        ob_start();

?>
         <table>
           <tr>
             <td width = "200">
               <?php

        echo $pm_debit['acc_holder'];

?>
             </td>
             <td>
               <input type = "text" class = "inputbox" name = "params[pm_debit][acc_holder]" id = "params[pm_debit][acc_holder]" />
             </td>
           </tr>
           <tr>
             <td>
               <?php

        echo $pm_debit['acc_number']

?>
             </td>
             <td>
               <input type = "text" class = "inputbox" name = "params[pm_debit][acc_number]" id = "params[pm_debit][acc_number]"/>
             </td>
           </tr>
           <tr>
             <td>
               <?php

        echo $pm_debit['bank_bic']

?>
             </td>
             <td>
               <input type = "text" class = "inputbox" name = "params[pm_debit][bank_bic]" id = "params[pm_debit][bank_bic]" />
             </td>
           </tr>
           <tr>
             <td>
               <?php

        echo $pm_debit['bank'];

?>
             </td>
             <td>
               <input type = "text" class = "inputbox" name = "params[pm_debit][bank]" id = "params[pm_debit][bank]" />
             </td>
           </tr>
         </table>
         <script type = "text/javascript">
          function pm_debit(){
			var ar_focus = new Array();
			var error = 0;
            unhighlightField('payment_form');
			if (isEmpty($F_("params[pm_debit][acc_holder]"))) {
				ar_focus[ar_focus.length] = "params[pm_debit][acc_holder]";
				error = 1;
			}
			if (isEmpty($F_("params[pm_debit][acc_number]"))) {
				ar_focus[ar_focus.length] = "params[pm_debit][acc_number]";
				error = 1;
			}
			if (!isInt_5_8($F_("params[pm_debit][bank_bic]"))) {
				ar_focus[ar_focus.length] = "params[pm_debit][bank_bic]";
				error = 1;
			}
			if (isEmpty($F_("params[pm_debit][bank]"))) {
				ar_focus[ar_focus.length] = "params[pm_debit][bank]";
				error = 1;
			}
			if (error){
		        $_(ar_focus[0]).focus();
		        for (var i = 0; i<ar_focus.length; i++ ){
		           highlightField(ar_focus[i]);
		        }
				return false;
			}
			$_('payment_form').submit();
          }
         </script>
    	<?php

        $return = ob_get_contents();
        ob_get_clean();
        return $return;
    }

    function int_5_8($value)
    {
        $reg = '^[0-9]{5,8}$';
        return (ereg($reg, $value));
    }

    function checkPaymentInfo(&$params)
    {
        if (!pm_debit::int_5_8($params['bank_bic'])) {
            return 0;
        } else
            return 1;
    }

    function showEndForm(&$params)
    {
        ob_start();
        $return = ob_get_contents();
        ob_get_clean();
        return $return;
    }

    function getParams()
    {
        global $pm_debit;
        return $pm_debit;
    }

    function showAdminFormParams($params)
    {

    }

}

?>